package com.guigu.springcloud.controller;


import com.guigu.springcloud.service.PaymentFeignService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/consumer/hystrix")
public class PaymentFeignController {

    @Resource
    private PaymentFeignService paymentFeignService;

    @GetMapping(value = "/{id}")
    public String testHystrix_Ok(@PathVariable("id") Long id) {
        return paymentFeignService.testHystrix_Ok(id);
    }

    @GetMapping
    public String testHystrix_Timeout() {
//        System.out.println(9 / 0);
        return paymentFeignService.testHystrix_Timeout();
    }

    // 服务熔断
    @GetMapping("/circuitBeaker/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Integer id) {
        return paymentFeignService.paymentCircuitBreaker(id);
    }

}
